function $(id) {
    return typeof id === "string" ? document.getElementById(id):null;
}
window.onload=function () {
    backnav();
    navlist();
    smartpro();
};
function backnav() {
    let time=null;/*设置定时器*/
    let index=0;/*设置图片index*/
    $("first").style.backgroundImage="url(\"../imgs/index"+index+".jpg\")";/*设置初始图片*/
    function timer() {
        if(index==2) {
            index=0;
            $("first").style.backgroundImage="url(\"../imgs/index"+index+".jpg\")";
        }
        else{
            index++;
            $("first").style.backgroundImage="url(\"../imgs/index"+index+".jpg\")";
        }
    }
    time=setInterval(timer,6000);
    $("first").onmouseover=function () {
        clearInterval(time);
    }
    $("first").onmouseout=function () {
        time=setInterval(timer,6000);/*定时器代码块*/
    }


}/*背景轮播图代码块*/
function navlist() {
    $("first_bar").onmouseleave=function(){
        for(let i=0;i<divname.length;i++){
            divname[i].style.display="none";
        }
    }
    let navname=$("nav_ul").getElementsByTagName("li");
    let divname=$("hidnav").getElementsByTagName("div");
    for(let i=1;i<divname.length+1;i++){
        navname[i].onmouseover=function () {
            for(let i=0;i<divname.length;i++){
                divname[i].style.display="none";
            }
            divname[i-1].style.display="block";
        }
    }
}/*导航栏二级菜单代码块*/
new Vue({
    el:'#app',
    data:{
        img:'../lunboimgs/timg0.png'
    },
    mounted:function() {
        this.firstmethod();
    },
    methods:{
        firstmethod:function () {
            let lis=$("UL").getElementsByTagName("li");
            let time=null;let index=0;let numindex=0;
            $("pic").setAttribute("src", this.img);
            lis[0].setAttribute("class","numindex");
            time=setInterval(function () {
                if(index==8){
                    for(let i=0;i<lis.length;i++){
                        lis[i].className="";
                    }
                    index=0;
                    $("pic").setAttribute("src","../lunboimgs/timg"+index+".png");
                    lis[index].setAttribute("class","numindex");
                    return;
                }else{
                    for(let i=0;i<lis.length;i++){
                        lis[i].className="";
                    }
                    lis[index].setAttribute("class","numindex");
                    $("pic").setAttribute("src","../lunboimgs/timg"+index+".png");
                    index+=1;
                }
            },3000);
            //定时器
        }
    }
});/*vue产品轮播代码*/
function smartpro() {
    let smartpros=$("ban_top4").getElementsByTagName("li");
    for(let i=0;i<3;i++){
        smartpros[i].onmouseover=function(){
            if(i==0){
                smartpros[1].style.left="1120px";
                smartpros[2].style.left="1160px";
            }else if(i==1){
                smartpros[1].style.left="40px";
                smartpros[2].style.left="1160px";
            }else{
                smartpros[1].style.left="40px";
                smartpros[2].style.left="80px";
            }
        }
        smartpros[i].onmouseout=function(){
            smartpros[0].style.left="0px";
            smartpros[1].style.left="400px";
            smartpros[2].style.left="800px";
        }
    }
}/*方案js缓动动画*/



